home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / bbs_soft / mrun210.zip / MRUN210F.WAS < prev    next >
Text File  |  1993-04-28  |  11KB  |  459 lines

  1. ;MailRun v2.10:  Part F, othercmds
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file is a grab bag of routines for the following:
  8. * adding an item to Get or Send Mail; adding an item to send a
  9. * command; adding an item to execute a script; displaying the 
  10. * "About MailRun" dialog box.  The appropriate routine is 
  11. * selected with a FLAG.
  12. **************************************************************************
  13. **************************************************************************
  14. #endcomment
  15.  
  16. #define MRUN210F
  17.  
  18. #include "mrun210.h"
  19.  
  20. string Command, ScriptName, ScriptList, MRunIcons
  21. integer GetSendRadio, IconIndex
  22.  
  23.  
  24. #comment
  25. *********************************************************************
  26. * MAIN()
  27. * Calls checkchild(), addgetmail(), addsendcommand(), 
  28. * adddoscript(), showabout(), menudim()
  29. * Calls the appropriate function based on the value of
  30. * FLAGS.
  31. *********************************************************************
  32. #endcomment
  33.  
  34. proc main
  35. integer cmdstatus
  36.     menudim()
  37.     checkchild()
  38.     findfirst MailRun
  39.     MailRunTrunc = $FILENAME
  40.     cmdstatus = FLAGS & (AGM + CMD + SCR + ABT)
  41.     switch cmdstatus
  42.         case AGM
  43.             addgetmail()
  44.         endcase
  45.         case CMD
  46.             addsendcommand()
  47.         endcase
  48.         case SCR
  49.             adddoscript()
  50.         endcase
  51.         case ABT
  52.             showabout()
  53.         endcase
  54.     endswitch
  55. endproc
  56.  
  57.  
  58. #comment
  59. *********************************************************************
  60. * ADDGETMAIL()
  61. * Called by main()
  62. * Calls getbbsi(), getitemi(), getbbscoord(), getitemcoord(),
  63. * getmailbox(), gettaskstring(), makebbslist(),
  64. * checkperm(), insertitem(), interfaceon()
  65. * Adds a GetMail item to the mailrun.
  66. *********************************************************************
  67. #endcomment
  68.  
  69. proc addgetmail
  70. string GetMailString, StatString
  71. string GetSendMail
  72. string Perm
  73. integer dialogstatus
  74. integer i, j
  75.     i = getbbsi()
  76.     j = getitemi()
  77.     makebbslist()
  78.     getmailbox()
  79.     statmsg ""
  80.     interfaceon()
  81.     while 1
  82.         dialogstatus = $DIALOG
  83.         switch dialogstatus
  84.             case 10
  85.                 ;User selected "Add"
  86.                 if GetSendRadio == 1
  87.                     GetSendMail = "GetMail"
  88.                     strfmt StatString "Added to %s:  `"Get QWK Packet`"" BBS
  89.                 else
  90.                     GetSendMail = "SendMail"
  91.                     strfmt StatString "Added to %s:  `"Send REP Packet`"" BBS
  92.                 endif
  93.                 Perm = checkperm()
  94.                 strfmt GetMailString "1,%s,%s" Perm GetSendMail
  95.                 ;Update MAILRUN.INI, task list
  96.                 j++
  97.                 insertitem(j, GetMailString)
  98.                 TaskItem = gettaskstring(i, j)
  99.                 statmsg StatString
  100.             endcase
  101.             case 11
  102.                 ;User selected "Done"
  103.                 exit
  104.             endcase
  105.             case 170
  106.                 ;User changed BBS with combobox
  107.                 i = getbbscoord()
  108.                 j = getitemcoord()
  109.                 TaskItem = gettaskstring(i, 0)
  110.             endcase
  111.         endswitch
  112.     endwhile
  113. endproc
  114.  
  115.  
  116. #comment
  117. *********************************************************************
  118. * GETMAILBOX()
  119. * Called by addgetmail()
  120. * Displays the Get/Send Mail dialog box.
  121. *********************************************************************
  122. #endcomment
  123.  
  124. proc getmailbox
  125. PermRadio = 1
  126. GetSendRadio = 1
  127. destroydlg
  128. HelpPage = 8
  129. dialogbox 52 68 243 93 15 "Get/Send Mail" HELPID HelpPage
  130.    radiobutton 16 44 54 14 "Get Mail" GetSendRadio
  131.    radiobutton 16 63 54 14 "Send Mail" endgroup
  132.    radiobutton 94 44 54 14 "Permanent" PermRadio
  133.    radiobutton 94 63 54 14 "Temporary" endgroup
  134.    pushbutton 184 44 40 14 "&Add" normal default
  135.    pushbutton 184 63 40 14 "&Done" normal
  136.    text  52 12 68 8 right "Get/Send Mail for:"
  137.    combobox 124 10 67 41 BBSList BBS sort
  138. enddialog
  139. endproc
  140.  
  141.  
  142. #comment
  143. *********************************************************************
  144. * ADDSENDCOMMAND()
  145. * Called by main()
  146. * Calls getbbsi(), getitemi(), getbbscoord(), getitemcoord(),
  147. * gettaskstring(), makebbslist(), interfaceon(),
  148. * sendcommandbox(), checkperm(), insertitem()
  149. * Adds a "SendCommand" item to the mailrun.  A command
  150. * string may contain multiple command lines separated by
  151. * verticle bars.  Successive command lines will be sent
  152. * when the terminal screen is quiet for 15 seconds.
  153. *********************************************************************
  154. #endcomment
  155.  
  156. proc addsendcommand
  157. string CommandString, StatString
  158. string Perm
  159. integer dialogstatus
  160. integer i, j
  161.     i = getbbsi()
  162.     j = getitemi()
  163.     makebbslist()
  164.     sendcommandbox()
  165.     statmsg ""
  166.     interfaceon()
  167.     while 1
  168.         dialogstatus = $DIALOG
  169.         switch dialogstatus
  170.             case 10
  171.                 ;User selected "Add"
  172.                 Perm = checkperm()
  173.                 strfmt CommandString "1,%s,SendCommand,%s" Perm Command
  174.                 strfmt StatString "Added to %s:  `"Send Command:  %s`"" \
  175.                     BBS Command
  176.                 j++
  177.                 insertitem(j, CommandString)
  178.                 TaskItem = gettaskstring(i, j)
  179.                 statmsg StatString
  180.             endcase
  181.             case 11
  182.                 ;User selected "Done"
  183.                 exit
  184.             endcase
  185.             case 170
  186.                 ;User changed BBS with the combobox
  187.                 i = getbbscoord()
  188.                 j = getitemcoord()
  189.                 TaskItem = gettaskstring(i, 0)
  190.             endcase
  191.         endswitch
  192.     endwhile
  193. endproc
  194.  
  195.  
  196. #comment
  197. *********************************************************************
  198. * SENDCOMMANDBOX()
  199. * Called by addsendcommand()
  200. * Displays the Send Command dialog box.
  201. *********************************************************************
  202. #endcomment
  203.  
  204. proc sendcommandbox
  205. PermRadio = 2
  206. Command = ""
  207. destroydlg
  208. HelpPage = 11
  209. dialogbox 92 63 196 124 15 "Send Command" HELPID HelpPage
  210.    text  8 39 42 8 right "Command:"
  211.    editbox 54 37 124 11 Command
  212.    radiobutton 32 85 59 11 "Permanent" PermRadio
  213.    radiobutton 32 101 59 11 "Temporary" endgroup
  214.    pushbutton 129 77 40 14 "&Add" normal default
  215.    pushbutton 129 97 40 14 "&Done" normal
  216.    text  30 15 68 8 right "Send Command to:"
  217.    combobox 102 13 65 42 BBSList BBS sort
  218.    text  54 51 97 8 left "Use a vertical bar (`"|`") to"
  219.    text  54 61 97 8 left "separate multiple commands."
  220. enddialog
  221. endproc
  222.  
  223.  
  224. #comment
  225. *********************************************************************
  226. * ADDDOSCRIPT()
  227. * Called by main()
  228. * Calls getbbsi(), getitemi(), getbbscoord(), getitemcoord(),
  229. * makebbslist(), makescriptlist(), interfaceon(),
  230. * gettaskstring(), scriptbox(), checkperm(), insertitem()
  231. * Adds a SendScript Item to the mailrun.
  232. *********************************************************************
  233. #endcomment
  234.  
  235. proc adddoscript
  236. string ScriptString, StatString
  237. string Perm
  238. integer dialogstatus
  239. integer i, j
  240.     i = getbbsi()
  241.     j = getitemi()
  242.     makebbslist()
  243.     makescriptlist()
  244.     scriptbox()
  245.     statmsg ""
  246.     interfaceon()
  247.     while dialogstatus != 1
  248.         dialogstatus = $DIALOG
  249.         switch dialogstatus
  250.             case 10
  251.                 ;User chose "Add"
  252.                 Perm = checkperm()
  253.                 strupr ScriptName
  254.                 strfmt ScriptString "1,%s,SendScript,%s" Perm ScriptName
  255.                 strfmt StatString "Added to %s:  `"Execute Script:  %s`"" \
  256.                     BBS ScriptName
  257.                 j++
  258.                 insertitem(j, ScriptString)
  259.                 TaskItem = gettaskstring(i, j)
  260.                 statmsg StatString
  261.             endcase
  262.             case 11
  263.                 ;User selected "Done"
  264.                 exit
  265.             endcase
  266.             case 170
  267.                 ;User changed BBS with the combobox
  268.                 i = getbbscoord()
  269.                 j = getitemcoord()
  270.                 TaskItem = gettaskstring(i, 0)
  271.             endcase
  272.         endswitch
  273.     endwhile
  274. endproc
  275.  
  276.  
  277. #comment
  278. *********************************************************************
  279. * MAKESCRIPTLIST()
  280. * Called by adddoscript()
  281. * Calls openfile(), makefullname()
  282. * Creates a list of scripts for display in the scriptbox()
  283. * dialog box script fcombobox.
  284. *********************************************************************
  285. #endcomment
  286.  
  287. proc makescriptlist
  288. string ScriptSpec, NextScript, ScriptLine
  289.     ScriptName = ""
  290.     ScriptList = makefullname(TempDir, "SCRIPTS.TMP")
  291.     openfile(ScriptFile, ScriptList, _CREATE, _TEXT)
  292.     ScriptSpec = makefullname(MailRunDir, "*.WA?")
  293.     findfirst ScriptSpec
  294.     ;Loop through all files in the directory
  295.     while FOUND
  296.         NextScript = $FNAME
  297.         strlwr NextScript
  298.         switch NextScript
  299.             case "MRUN210"
  300.             case "MRUN210A"
  301.             case "MRUN210B"
  302.             case "MRUN210C"
  303.             case "MRUN210D"
  304.             case "MRUN210E"
  305.             case "MRUN210F"
  306.             case "MRUN210G"
  307.             case "ARRAY"
  308.             case "HOST"
  309.             case "HOSTUTIL"
  310.             case "USER"
  311.             case "SUBS"
  312.             case "MAIL"
  313.             endcase
  314.             default
  315.                 rewind ScriptFile
  316.                 fgets ScriptFile ScriptLine
  317.                 while not NULLSTR ScriptLine
  318.                     if strcmp ScriptLine NextScript
  319.                         exitswitch
  320.                     endif
  321.                     fgets ScriptFile ScriptLine
  322.                 endwhile
  323.                 fputs ScriptFile NextScript
  324.                 if NULLSTR ScriptName
  325.                     ScriptName = NextScript
  326.                 endif
  327.             endcase
  328.         endswitch
  329.         findnext
  330.     endwhile
  331.     fclose ScriptFile
  332. endproc
  333.  
  334.  
  335. #comment
  336. *********************************************************************
  337. * SCRIPTBOX()
  338. * Called by adddoscript()
  339. * Displays the Execute Script dialog box.
  340. *********************************************************************
  341. #endcomment
  342.  
  343. proc scriptbox
  344. PermRadio = 2
  345. destroydlg
  346. ScriptName = "terminal"
  347. HelpPage = 12
  348. dialogbox 92 60 180 135 15 "Execute Script" HELPID HelpPage
  349.    text  14 36 64 8 right "Available Scripts:"
  350.    fcombobox 82 34 76 42 ScriptList ScriptName sort
  351.    text  20 54 136 22 left "WARNING:  Scripts must not alter \
  352. global variables s0-s9 and i0-i9!!!"
  353.    radiobutton 17 85 62 14 "Permanent" PermRadio
  354.    radiobutton 17 107 62 14 "Temporary" endgroup
  355.    pushbutton 114 85 40 14 "&Add" normal default
  356.    pushbutton 114 107 40 14 "&Done" normal
  357.    text  14 11 64 8 right "Execute Script at:"
  358.    combobox 82 9 76 42 BBSList BBS sort
  359. enddialog
  360. endproc
  361.  
  362.  
  363. #comment
  364. *********************************************************************
  365. * SHOWABOUT()
  366. * Called by main()
  367. * Calls aboutbox()
  368. * Displays the About MailRun dialog box.
  369. *********************************************************************
  370. #endcomment
  371.  
  372. proc showabout
  373. integer dialogstatus
  374.     statmsg ""
  375.     aboutbox()
  376.     dialogstatus = $DIALOG
  377.     while dialogstatus != 1
  378.         dialogstatus = $DIALOG
  379.     endwhile
  380.     exit
  381. endproc
  382.  
  383.  
  384. #comment
  385. *********************************************************************
  386. * ABOUTBOX()
  387. * Called by showabout()
  388. * Calls makefullname()
  389. * Displays the About MailRun dialog box.
  390. *********************************************************************
  391. #endcomment
  392.  
  393. proc aboutbox
  394. destroydlg
  395. HelpPage = 1
  396. MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL")
  397. IconIndex = 17
  398. dialogbox 55 55 220 151 15 "About MailRun" HELPID HelpPage
  399.    text  42 14 136 27 center "MailRun`r`nVersion 2.10`r`n\
  400. Copyright ⌐ 1992-1993 Gerald P. Sully"
  401.    text  20 48 180 28 left "If you use MailRun with any regularity, \
  402. ease your aching conscience by helping out a starving author.`r`n\
  403. Send $15 to:"
  404.    icon 160 82 MRunIcons IconIndex
  405.    text  20 80 120 44 left "Jerry Sully`r`n841 Solano Ave. #2`r`n\
  406. Albany, CA  94706`r`n`r`nThank you for your support!"
  407.    pushbutton 20 128 180 12 "I promise I'll send $15 as soon as I \
  408. can afford it!" cancel
  409. enddialog
  410. endproc
  411.